home *** CD-ROM | disk | FTP | other *** search
- Path: sage.cgd.ucar.edu!jadams
- From: jadams@sage.cgd.ucar.edu (James Adams)
- Newsgroups: comp.lang.c++,gnu.g++.help
- Subject: Unable to compile inline functions
- Date: 2 Apr 1996 20:00:08 GMT
- Organization: National Center for Atmospheric Research
- Distribution: world
- Message-ID: <4js108$pm4@ncar.ucar.edu>
- Reply-To: jadams@sage.cgd.ucar.edu
- NNTP-Posting-Host: sage.cgd.ucar.edu
-
- Hello,
-
- I am attempting to compile a C++ program which has member functions
- defined as inline, and I get unresolved errors from my linker. For instance
- I have a class defined as such:
-
- class nrifframe {
- private:
- // private member variables
- int count;
- char *filename;
- FILE *infile;
- header *head;
- pix48 *data;
- public:
- // public member functions
- nrifframe ();
- ~nrifframe ();
- bool initialize (char *name);
- int getwidth ();
- int getheight ();
- };
-
- I have defined the inline functions (in another file) as such:
-
- inline int nrifframe::getheight()
- {
- return(this->head->y);
- }
-
- The errors I am getting from ld:
-
- collect2: ld returned 1 exit status
- /bin/../lib/ld:
- Unresolved:
- nrifframe::getheight(void)
-
-
- I have a reference (C++ Complete, Schildt, p293) which shows this to be
- the correct method of declaring/defining inline functions. Have I
- missed something ? (I prefer this over the somewhat messy [but maybe
- more correct ?] method of defining the function on the same line as
- its declaration in the class declaration)
-
- I am using g++ on an SGI Indy.
-
- My command is "g++ -o executable main.cpp file1.cpp"
-
-
- Thanks for any help/suggestions/advice ! Please email responses
- if possible.
-
-
- -James
- --
- ---------------------------------------------------------------------------
- James Adams Email: jadams@ucar.edu
- National Center for Atmospheric Research Phone: (303) 497-1356
- Boulder, Colorado Fax: (303) 497-1348
-
- WWW: http://www.cgd.ucar.edu/ccr/jadams/home.html
-